package com.example.creditscore;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Vibrator;
import android.util.Log;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class methods extends Credit_score_form_sec_a {
	
	static int id;
	static String variable;
	static EditText et;
	public static String VexistingCustomer;
	public static EditText edittext;
	//public static EditText methodEditText;

		



	public void editorSharePreferences(Context ctx, String dataName,
			String valueToAddIn) {
		SharedPreferences preferences = ctx.getSharedPreferences("Mb4Me", 0);
		SharedPreferences.Editor editor = preferences.edit();

		editor.putString(dataName, valueToAddIn);
		editor.commit();

	}

	public void editorShareIntPreferences(Context ctx, String dataName,
			int valueToAddIn) {
		SharedPreferences preferences = ctx.getSharedPreferences("Mb4Me", 0);
		SharedPreferences.Editor editor = preferences.edit();

		editor.putInt(dataName, valueToAddIn);
		editor.commit();

	}

	public String retriveSharePreference(Context ctx, String retriveValue,
			String dataName) {
		SharedPreferences preferences = ctx.getSharedPreferences("Mb4Me", 0);
		retriveValue = preferences.getString(dataName, null);
		return retriveValue;
	}
	
	public String retriveSharePreferenceForServer( String retriveValue,
			String dataName) {
		SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
		retriveValue = preferences.getString(dataName, null);
		return retriveValue;
	}

	public Integer retriveShareIntPreference(Context ctx, int retriveValue,
			String dataName) {
		SharedPreferences preferences = ctx.getSharedPreferences("Mb4Me", 0);
		retriveValue = preferences.getInt(dataName, retriveValue);
		return retriveValue;
	}

	public String setExistingCustomer() {
		return VexistingCustomer;
	}

	// get getTextValue
	// here
	public void getEditTextValue(Context ctx, int resources, String  DataValue , String vEditTextValue) {
		
		methods md = new methods();
		System.out.println("Resources1 " + resources);
		//System.out.println("edittext1 " + editTextName);
		Log.d("getEDITTEXT" , "getEditText1 " + resources);
		
		Log.d("getEDITTEXT" , "getEditText2 " + edittext);
		try{
			 edittext = (EditText) findViewById(resources);
		}catch (NullPointerException ne){
		Log.d("getEDITTEXT" , "getEditText4 " + resources);
		Log.d("getEDITTEXT" , "getEditText5 " + edittext);
		Log.d("getEDITTEXT" , "getEditText6 " + ne);
		}
		Log.d("getEDITTEXT" , "getEditText7daryl " + edittext);
		vEditTextValue = edittext.getText().toString();
		Log.d("getEDITTEXT" , "getEditText8daryl " + edittext);
		Log.d("getEDITTEXT" , "getEditText9daryl " + vEditTextValue);
		md.editorSharePreferences(ctx, DataValue, vEditTextValue);

	}

	// set setTextValue
	public void setEditTextValue(EditText edittext, int resources, String DataValue) {

		methods md = new methods();
		System.out.println("Resources2 " + resources);
		edittext  = (EditText) findViewById(resources);
		edittext.setText(md.retriveSharePreference(this, "vEditTextValue",
				DataValue));

	}

	

}
